<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="commons/css::css">head</th:block>
</head>

<body class="flat-blue">
<i style="display: none;" id="_manager_url" url="/customer/manager"></i>
<div class="app-container">
    <div class="row content-container">
        <th:block th:include="commons/nav_head::nav">head</th:block>
        <th:block th:include="commons/side::side">side</th:block>
        <!-- Main Content -->
        <div class="container-fluid">
            <div class="side-body">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                会员信息
                            </div>
                            <div class="panel-body form-group col-sm-offset-1 table-bordered">
                                <div class="form-group">
                                    <div class="col-sm-5">
                                        <label class="col-sm-3">账号</label>
                                        <div class="col-sm-4">
                                            <input type="hidden" id="id" name="id" th:value="${customer.id}">
                                            <span th:text="${customer.account}?${customer.account}"></span>
                                        </div>
                                    </div>

                                    <div class="col-sm-5">
                                        <label class="col-sm-3" th:text="${customer.type}==1?'昵称':'商户名称'"></label>
                                        <div class="col-sm-4">
                                            <span th:text="${customer.alias}"></span>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-sm-5">
                                        <label class="col-sm-3" th:text="${customer.type==1}?'头像':'商标'">头像</label>
                                        <div class="col-sm-4">
                                            <img th:src="${customer.headImg}" style="width: 80px; height: 80px;">
                                        </div>
                                    </div>

                                    <div class="col-sm-5" th:if="${customer.type==2}">
                                        <label class="col-sm-3">营业执照</label>
                                        <div class="col-sm-4">
                                            <img th:src="${customer.businessLicense}"
                                                 style="width: 80px; height: 80px;">
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-sm-5">
                                        <label class="col-sm-3" th:text="${customer.type}==1?'生日':'注册日期'"></label>
                                        <div class="col-sm-4">
                                            <span th:text="${#dates.format(customer.birthday, 'yyyy-MM-dd')}"></span>
                                        </div>
                                    </div>

                                    <div class="col-sm-5" th:if="${customer.type==2}">
                                        <label class="col-sm-3">商户注册日期</label>
                                        <div class="col-sm-4">
                                            <span th:text="${customer.regTime}?${#dates.format(customer.regTime, 'yyyy-MM-dd')}"></span>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-sm-5">
                                        <label class="col-sm-3">口号</label>
                                        <div class="col-sm-4">
                                            <span th:text="${customer.sologan}"></span>
                                        </div>
                                    </div>

                                    <div class="col-sm-5">
                                        <label class="col-sm-3">介绍</label>
                                        <div class="col-sm-4">
                                            <span th:text="${customer.selfIntroduce}"></span>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group row" th:if="${customer.type==2}">
                                    <div class="col-sm-5">
                                        <label class="col-sm-3">审核状态</label>
                                        <div class="col-sm-4">
                                            <div th:switch="${customer.auditStatus}" th:remove="tag">
                                                <th:block th:case="1">待审核</th:block>
                                                <th:block th:case="2">审核通过</th:block>
                                                <th:block th:case="3">审核不通过</th:block>
                                                </span>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group row" th:if="${customer.type==2} and ${customer.auditStatus==1}">
                                    <div class="col-sm-5">
                                        <label class="col-sm-3">审核意见</label>
                                        <div class="col-sm-4">
                                                <span th:switch="${customer.auditStatus}">
                                                    <select th:case="1" class="select selectpicker" id="auditStatus">
                                                        <option value="2">审核通过</option>
                                                        <option value="3">审核不通过</option>
                                                    </select>
                                                </span>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group row" th:if="${customer.type==2} and ${customer.auditStatus==1}">
                                    <label class="col-sm-1">审核说明</label>
                                    <div>
                                        <textarea style="margin-left: 55px;" cols="50" rows="5" id="auditDescription" name="auditDescription">

                                        </textarea>
                                    </div>
                                </div>

                                <div class="form-group row" th:if="${customer.type==2} and ${customer.auditStatus!=1}">
                                    <label class="col-sm-1">审核说明</label>
                                    <div style="margin-left: 55px;" th:text="${customer.auditDescription}">

                                    </div>
                                </div>

                                <div class="form-group row" th:if="${customer.type==2}">
                                    <div class="form-group">
                                        <div class="col-sm-offset-2 col-sm-3">
                                            <button type="button" class="btn btn-info" id="btn-submit"
                                                    th:if="${customer.type==2} and ${customer.auditStatus==1}">
                                                <span class="fa fa-adjust"> 审核</span>
                                            </button>
                                            <button type="button" class="btn btn-info"
                                                    onclick="document.location.replace(ctx + '/customer/manager');">
                                                <span class="glyphicon glyphicon-backward">返回</span>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<th:block th:include="commons/js::js">Javascript Libs</th:block>
<script>
    $(function () {
        $("#btn-submit").click(function () {
            var customer = {id: $("#id").val(), auditStatus: $("#auditStatus").val(), auditDescription: $("#auditDescription").val()};
            $.post(ctx + "/customer/auditCustomer", customer,  function (rtn) {
                if (rtn.code != 1) {
                    Alert("操作失败");
                    return;
                }
                document.location.replace(ctx + '/customer/manager');
            });
        });
    })
</script>
</html>